<?php

/**
 * This is the model class for table "affectation".
 *
 * The followings are the available columns in table 'affectation':
 * @property integer $ID_AFFECTATION
 * @property integer $ID_BILLET_INCIDENT
 * @property string $DATE_PRISE_EN_CHARGE
 * @property integer $ID_PERSONNEL_TECHNIQUE
 * @property string $COMMENTAIRES_AFFECTATION
 *
 * The followings are the available model relations:
 * @property PersonnelTechnique $iDPERSONNELTECHNIQUE
 * @property BilletIncident $iDBILLETINCIDENT
 */
class Affectation extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Affectation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'affectation';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ID_AFFECTATION, ID_BILLET_INCIDENT, DATE_PRISE_EN_CHARGE, ID_PERSONNEL_TECHNIQUE', 'required'),
			array('ID_AFFECTATION, ID_BILLET_INCIDENT, ID_PERSONNEL_TECHNIQUE', 'numerical', 'integerOnly'=>true),
			array('COMMENTAIRES_AFFECTATION', 'length', 'max'=>500),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_AFFECTATION, ID_BILLET_INCIDENT, DATE_PRISE_EN_CHARGE, ID_PERSONNEL_TECHNIQUE, COMMENTAIRES_AFFECTATION', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'iDPERSONNELTECHNIQUE' => array(self::BELONGS_TO, 'PersonnelTechnique', 'ID_PERSONNEL_TECHNIQUE'),
			'iDBILLETINCIDENT' => array(self::BELONGS_TO, 'BilletIncident', 'ID_BILLET_INCIDENT'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_AFFECTATION' => 'Id Affectation',
			'ID_BILLET_INCIDENT' => 'Id Billet Incident',
			'DATE_PRISE_EN_CHARGE' => 'Date Prise En Charge',
			'ID_PERSONNEL_TECHNIQUE' => 'Id Personnel Technique',
			'COMMENTAIRES_AFFECTATION' => 'Commentaires Affectation',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_AFFECTATION',$this->ID_AFFECTATION);
		$criteria->compare('ID_BILLET_INCIDENT',$this->ID_BILLET_INCIDENT);
		$criteria->compare('DATE_PRISE_EN_CHARGE',$this->DATE_PRISE_EN_CHARGE,true);
		$criteria->compare('ID_PERSONNEL_TECHNIQUE',$this->ID_PERSONNEL_TECHNIQUE);
		$criteria->compare('COMMENTAIRES_AFFECTATION',$this->COMMENTAIRES_AFFECTATION,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}